<?php 
class Currency extends CActiveRecord
{
	public $id;
	public $name;
	public $code;
	public $rate;
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return User the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'currencies';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		return array(
		);
	}

	public static function getValueCurrency($name) {
		$model = Currency::model()->findByAttributes(array('name'=>$name));
		if(is_object($model)) {
			return $model->rate;
		}
		return 0;
	}
}
?>